package com.zj.core.ui

import android.content.Context
import android.support.constraint.ConstraintLayout
import android.view.Gravity
import android.view.View
import android.widget.EditText
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.zj.core.R
import org.jetbrains.anko.*
import org.jetbrains.anko.constraint.layout.constraintLayout
import org.jetbrains.anko.constraint.layout.guideline

class SearchDialogUi(context: Context) {
    private var mContext: Context = context
    var common_dialog_message_tv: EditText?=null
    var guide_line_lly: LinearLayout?=null
    var voice_img_view: ImageView?=null
    var search_voice:TextView?=null
    var common_dialog_root_view: ConstraintLayout? = null

    init {
        common_dialog_root_view = mContext.constraintLayout {
            lparams(width = matchParent, height = matchParent)
            id = R.id.parent_cs_layout
            backgroundColor = resources.getColor(R.color.colortm)

            guideline {
                id = R.id.guide_line_left
            }.lparams(width = wrapContent, height = matchParent) {
                orientation = ConstraintLayout.LayoutParams.VERTICAL
                guidePercent = 0.1F
            }

            guideline {
                id = R.id.guide_line_right
            }.lparams(width = wrapContent, height = matchParent) {
                orientation = ConstraintLayout.LayoutParams.VERTICAL
                guidePercent = 0.9F
            }

            guideline {
                id = R.id.guide_line_h_center
            }.lparams(width = matchParent, height = wrapContent) {
                orientation = ConstraintLayout.LayoutParams.HORIZONTAL
                guidePercent = 0.5F
            }

            guide_line_lly=linearLayout {
                id = R.id.guide_line_lly
                background = resources.getDrawable(R.drawable.popup_dialog_bg)
                orientation = LinearLayout.HORIZONTAL
                gravity=Gravity.CENTER_VERTICAL
                setPadding(dip(10),0,dip(10),0)

                common_dialog_message_tv=editText {
                    id = R.id.common_dialog_message_tv
                    gravity =Gravity.CENTER_VERTICAL
                    background=null
                    singleLine = true
                    hint = "可根据 床号/时间 进行搜索"
                    textSize = dip(10).toFloat()
                    textColor = resources.getColor(R.color.colorsNote)
                }.lparams(width = 0, height = wrapContent) {
                    weight=1F
                    topMargin=dip(10)
                    bottomMargin=dip(10)
                }

                search_voice=textView{
                    text="搜索"
                    id=R.id.search_voice
                    gravity =Gravity.CENTER
                    setPadding(0,dip(10),0,dip(10))
                }.lparams(width= wrapContent,height =wrapContent)
            }.lparams(0, wrapContent) {
                leftToLeft=ConstraintLayout.LayoutParams.PARENT_ID
                rightToRight=ConstraintLayout.LayoutParams.PARENT_ID
                topToTop=ConstraintLayout.LayoutParams.PARENT_ID
            }

            voice_img_view=imageView {
                image = resources.getDrawable(R.mipmap.ease_record_animate_01)
                id = R.id.voice_img_view
                visibility = View.GONE
            }.lparams(dip(50), dip(60)) {
                leftToRight = R.id.guide_line_left
                rightToLeft = R.id.guide_line_right
                topToBottom = R.id.guide_line_h_center
                bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID
            }
        }
    }
}